package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements SwithButton.OnSwitchStatusChangeListener{
    private SwithButton mSbBtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSbBtn = (SwithButton) findViewById(R.id.sb_one);
        mSbBtn.setSwitchButtonBackGroundResource(R.drawable.switch_bg);
        mSbBtn.setSwitchButtonBlockResource(R.drawable.switch_block);
        mSbBtn.setOnSwitchStatusChangeListener(this);
    }

    @Override
    public void onChange(SwithButton.SwitchStatus status) {
        String msg = status == status.CLOSE?"目前是关闭的":"目前是打开的";
        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
    }
}
